package com.rainbow.config.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

/**
 * Auth rainbow
 */
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("插入字段");
        this.setFieldValByName("createTime", new Date(), metaObject);
        //this.setFieldValByName("createBy", user.getId(), metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("更新字段");
        this.setFieldValByName("updateTime", new Date(), metaObject);
        //this.setFieldValByName("updateBy",user.getId(),metaObject);
    }
}
